package cn.hloger.spider.demo.carDemo.carDemo;

import cn.hutool.crypto.asymmetric.Sign;
import cn.hutool.crypto.asymmetric.SignAlgorithm;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;

/**
 * 正式的
 *
 * @author huanglong
 * @Description TODO
 * @data 2022/9/12
 */
@Service
public class RASTest {

//    public static String private_key = "MIICXAIBAAKBgQDONrM8hm7ow+akr2v2AQvyL2hRPTFxfNBN2XeyK8AAI3E8kvLbtKLPptiRUx5C6kxFefq6Kn0yVPGdL83nTteqyj0x0gp58o1YOAu0epE0zVgUafmETUDq9r+yTHdnmdqwMR2+uDV7Ey5Tmy8/WRjISiZmG1C3rOAnRXTNOgUrhQIDAQABAoGAGsBx5Co0fTHc3AR95v4fxJ1t1QwxO93LUC4kHxMZ52qxqAAQTXxTmsi0U7YKuPeYSXMXmcslTsBCT/gBqD5ML/nyTg3kP7+uWkeOFe8MWCga+R94Y2OfXGOM024HOaCq+mpy8HyiRL9xKrVCJ+kdhPqt92kmyRk1qKXpsif88MECQQD/9MvDb2x3XiGPtkZae2QfJw3L7D8GrCbM5WJxAEd+VvFtCqgc0GpNPRx4PG7YKKf6rYHE9oZpiGgBtdcyY+4ZAkEAzj+6D0JMLGmCPONjArBd00DyjOdOMCgBrpqRiGaTMXojK/m1AFzk4XdDWT3va0aKagBTl6BIRIY9+5c2iUC+TQJBAI4WOatDRoY5Ng5OVF3UU69LgcgrXI16sYta5zvtuMJ0x08N9GcSd4BrJUvF2I6ceyuYeAp8A/+/nmUcqdqqSLkCQBXjR3CVHZZdABhMHVbMtrhTnSn85hxQMpWAC8/I6vgGOTNShbXrJdMToA8Zdo4Q52GGdViTBvhWsr8/decs+sUCQE9zP0cky6yo/yDO+5Pg7iR4/Lmdf/Yn5hCZsufTXSBvQFsgTtUEdiohKdTwuzz5l1cjjxQYJGrYVl97307DLXI=";

    public static String private_key = "MIICXAIBAAKBgQDONrM8hm7ow+akr2v2AQvyL2hRPTFxfNBN2XeyK8AAI3E8kvLbtKLPptiRUx5C6kxFefq6Kn0yVPGdL83nTteqyj0x0gp58o1YOAu0epE0zVgUafmETUDq9r+yTHdnmdqwMR2+uDV7Ey5Tmy8/WRjISiZmG1C3rOAnRXTNOgUrhQIDAQABAoGAGsBx5Co0fTHc3AR95v4fxJ1t1QwxO93LUC4kHxMZ52qxqAAQTXxTmsi0U7YKuPeYSXMXmcslTsBCT/gBqD5ML/nyTg3kP7+uWkeOFe8MWCga+R94Y2OfXGOM024HOaCq+mpy8HyiRL9xKrVCJ+kdhPqt92kmyRk1qKXpsif88MECQQD/9MvDb2x3XiGPtkZae2QfJw3L7D8GrCbM5WJxAEd+VvFtCqgc0GpNPRx4PG7YKKf6rYHE9oZpiGgBtdcyY+4ZAkEAzj+6D0JMLGmCPONjArBd00DyjOdOMCgBrpqRiGaTMXojK/m1AFzk4XdDWT3va0aKagBTl6BIRIY9+5c2iUC+TQJBAI4WOatDRoY5Ng5OVF3UU69LgcgrXI16sYta5zvtuMJ0x08N9GcSd4BrJUvF2I6ceyuYeAp8A/+/nmUcqdqqSLkCQBXjR3CVHZZdABhMHVbMtrhTnSn85hxQMpWAC8/I6vgGOTNShbXrJdMToA8Zdo4Q52GGdViTBvhWsr8/decs+sUCQE9zP0cky6yo/yDO+5Pg7iR4/Lmdf/Yn5hCZsufTXSBvQFsgTtUEdiohKdTwuzz5l1cjjxQYJGrYVl97307DLXI=";

    public static Sign sign = new Sign(SignAlgorithm.SHA256withRSA, private_key, null);

    public static String sign2(String content) {
        return EncryptUtils.sign(sign, content);
    }

    public static void main(String[] args) throws Exception {
        JSONObject json = new JSONObject();
//        json.put("image", "");
        json.put("data", "SEOiNZR0ZflHIJQaknucW9xY+9SifEXnWRTkxV+5bWY/RLPtsdC4VAJNoI2DFgRrXkfz43NGMMe08Yxl61q8QHNHNxD9+qVagO+H5+QIbDPtYPaA5Xy69ZLCSSp6iX6+/af8bxNqzBE3N/LQYNOJqOfN0eMv4phiZ7l1PhmuFz6xCPEBntm1cqtsGP/3vcUPGXmStBo+QqtE+v+dB+TZHzyQpffEP2GFlgmY3sbt63N8zYVX6jDTQ4xD0BPuB1LrsqHowjmWyJb2P+qWynVYw6I5sVC3r94I9x/NFh8IfmFiB/erOXdpQ40O6OGsgM5MI99s54oM73IKUo+t9ZnoW6FtRP/u1wJ0UTbBAWlB5LNQak7NvY5Bz1SpmLJx9kYOH2e+4p7ZLMJniEXkSaTQzRkWkCtteIGGvGlzQaKVyZeSyf/izENMI9HHEYpf+U66uhliYjK2k54JC47QHikDJ2IPpmuSXSSZr3R078/n9pgI7DxV+s7zvJ8192bHbqtWGocxTaIKO4zh/IFJcOzazQKvLOKrH4CbM+odVCXkkY9T2a8wA/0H0XyeZAUBc6ey");
        json.put("version", "1.0");
        json.put("app_id", "202309080099");
        json.put("timestamp", "20230908181806");
        //ras加密
        String content = EncryptUtils.getSortContent(json);
        String sign = sign2(content);
        System.out.println(content);
        System.out.println(sign);
        System.out.println("================================");
    }
}
